//
//  SetUserInfoApi.m
//  SmartClothes
//
//  Created by Rex on 16/4/22.
//  Copyright © 2016年 Rex. All rights reserved.
//

#import "SetUserInfoApi.h"
@implementation SetUserInfoApi
{
    NSDictionary *_info;
}

- (id)initWithInfo:(NSDictionary *)info  {
    self = [super init];
    if (self) {
        _info = info;
    }
    return self;
}

- (NSString *)requestUrl {
    return @"/new/user/set_user_info";
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (AFConstructingBlock)constructingBodyBlock
{
    if ([NSData dataWithContentsOfFile:_info[@"image"]] == nil) {
        return nil;
    }
    return ^(id<AFMultipartFormData> formData) {
        NSError *error;
    
        [formData appendPartWithFileURL:[NSURL fileURLWithPath:_info[@"image"]] name:@"image" error:&error];
      
    };
}




- (id)requestArgument {



    NSMutableDictionary * mdic = [NSMutableDictionary getPubdic];

    if (_info[@"nickname"] != nil){
        [mdic setObject:_info[@"nickname"] forKey:@"nickname"];
    }
    if (_info[@"sex"]!= nil) {
        [mdic setObject:_info[@"sex"] forKey:@"sex"];
    }
    if (_info[@"birth"]!= nil) {
        [mdic setObject:_info[@"birth"] forKey:@"birth"];
    }
    if (_info[@"height"]!= nil) {
        [mdic setObject:_info[@"height"] forKey:@"height"];
    }
    if (_info[@"weight"]!= nil) {
        [mdic setObject:_info[@"weight"] forKey:@"weight"];
    }
    
    NSString * sign = [NSString getSign:mdic];
    [mdic setObject:sign forKey:@"sign"];
    
    return mdic;
}






@end
